package com.sicheng.蓝桥.练习题.基础数论;

/**
 * @author zsc
 * @version 1.0
 * @date 2022/5/5 17:19
 */
public class 快速幂模板 {
    public static void main(String[] args) {

    }

    public static long mi(long m, long n, long p) {
        //防止p=1出错
        long res = 1 % p;
        if (res != 0)
            while (n > 0) {
                if ((n & 1) == 1) {
                    res = res * m % p;
                }
                n >>= 1;
                m = m * m % p;
            }
        return res;
    }
}
